package org.soarsky.wealthchengdu.module.info;

import java.util.ArrayList;
import java.util.List;

import org.soarsky.wealthchengdu.R;
import org.soarsky.wealthchengdu.appliction.MyAppliction;
import org.soarsky.wealthchengdu.google.map.MapActivityContor;
import org.soarsky.wealthchengdu.google.map.MapActivityTravel;
import org.soarsky.wealthchengdu.google.map.MapUtils;
import org.soarsky.wealthchengdu.language.LanguageUtil;
import org.soarsky.wealthchengdu.module.guide.GAODEMapActivity;
import org.soarsky.wealthchengdu.module.guide.GuideDelitActivity;
import org.soarsky.wealthchengdu.module.home.HomeActivty;
import org.soarsky.wealthchengdu.module.load.StarActivity;
import org.soarsky.wealthchengdu.util.Config;
import org.soarsky.wealthchengdu.view.AddView;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

/**
 * 参会指南
 * 
 * @author huang
 * 
 */
public class GuidechengduDataShow extends AddView {

	private static GuidechengduDataShow guidechengduDataShow = null;
	private ListView guideList;// 参会指南listview
	private GuideCDlistAdapter guideCDlistAdapter;
	private LanguageUtil languagerutil;
	private Context mContext;
	protected GuidechengduDataShow(Activity activity) {
		super(activity);
		mContext = activity;
		
	}

	/**
	 * 获取GuidechengduDataShow实例s
	 * 
	 * @param context
	 * @return
	 */
	public static GuidechengduDataShow getinstace(Activity activity) {
		if (guidechengduDataShow == null) {
			guidechengduDataShow = new GuidechengduDataShow(activity);
		}
		return guidechengduDataShow;
	}

	/**
	 * 获取布局
	 * 
	 * @return
	 */
	public View getviewguide() {
		View view = getinfalntview(R.layout.activity_guide);
		initview(view);
		return view;
	}

	/**
	 * 获取控件
	 * 
	 * @param view
	 */
	private void initview(View view) {
		guideCDlistAdapter = new GuideCDlistAdapter(activity);
		guideList = (ListView) view.findViewById(R.id.activity_guide_listview);
		guideList.setAdapter(guideCDlistAdapter);
		guideList.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
					int position, long arg3) {
				listclick(position);
			}
		});
		setlist();
	}

	/**
	 * 设置数据
	 */
	private void setlist() {
		languagerutil = Config.changeLanguage(MyAppliction.mCn);
		List<GuideAppbean> list = new ArrayList<GuideAppbean>();
		GuideAppbean guideappbean = new GuideAppbean();
		guideappbean.guidetitle = languagerutil.getPartipants();
		guideappbean.image = R.drawable.look;
		list.add(guideappbean);
		GuideAppbean guideappbean1 = new GuideAppbean();
		guideappbean1.guidetitle = languagerutil.getLife();
		guideappbean1.image = R.drawable.life;
		list.add(guideappbean1);
		GuideAppbean guideappbean2 = new GuideAppbean();
		guideappbean2.guidetitle = languagerutil.getTravel();
		guideappbean2.image = R.drawable.lvxing;
		list.add(guideappbean2);
		guideCDlistAdapter.setlistdata(list);
	}

	/**
	 * listview的点击事件
	 * 
	 * @param position
	 */
	public void listclick(int position) {
		switch (position) {
		case 0:
			mContext.startActivity(new Intent(mContext.getApplicationContext(),GuideDelitActivity.class));
			break;
		case 1:
			if(MapUtils.isEnableGoogleMap()){
				mContext.startActivity(new Intent(mContext.getApplicationContext(),MapActivityContor.class));
			}else {
				Intent intent =new Intent(mContext.getApplicationContext(),GAODEMapActivity.class);
				intent.putExtra(GAODEMapActivity.MAP_STATUS, GAODEMapActivity.MAP_OTHER);
				mContext.startActivity(intent);
			}
			break;
		case 2:
			if(MapUtils.isEnableGoogleMap()){
				mContext.startActivity(new Intent(mContext.getApplicationContext(),MapActivityTravel.class));
			}else{
				Intent intent =new Intent(mContext.getApplicationContext(),GAODEMapActivity.class);
				intent.putExtra(GAODEMapActivity.MAP_STATUS, GAODEMapActivity.MAP_TRAVEL);
				mContext.startActivity(intent);
			}
			
			break;

		}
	}
	
}
